<?php
/**
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/4/23
 * Time: 11:50
 */

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Doraemon\model\Category as mCategory;
use Biz\cache\IniCategoryCode as cIniCategoryCode;
use Biz\module\Packages\Recommend\RecommendGoods as mdlRecommendGoods;

$file_path = "/home/adm_rsync_dir/category_code.json";

try{

    $result     = [];
    $categorys  = mCategory::getAllCategorys();
    if(!empty($categorys)){

        foreach ($categorys as  $categorys_v){

            $result['category'][$categorys_v['id']] = $categorys_v['cate_name'];
        }

        cIniCategoryCode::setCategoryCode($result);

        echo printf("%s,%s",date('Y-m-d H:i:s'),'同步成功');
    } else {
        echo printf("%s,%s",date('Y-m-d H:i:s'),'当前没有需要同步的数据');
    }

} catch (\Exception $e){

    echo printf("出错,%s",$e->getMessage());
}